package com.ajax;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sql.DAO;

public class ChaXunKuang extends HttpServlet {

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		response.setContentType("text/xml;charset=UTF-8");
        response.setHeader("Cache-Control", "no-cache");
        response.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		String q = request.getParameter("q");
		DAO dao = new DAO();
		int a = Integer.parseInt(request.getParameter("a"));
		System.out.println(a);
		HttpSession session = request.getSession(false);
		if(q.equals("id")){}
		else if(q.equals("name")){}
		else if(q.equals("money")){
			out.print("<form action='' vertical-align='middle'>");
			out.print("在<input style='width:120px;' id='money0' value='0' onchange='showCustomer(this.value)' vertical-align='middle' type='text' name='fname' />");
			out.print("—<input style='width:120px;' id='money1' value='MAX' onchange='showCustomer(this.value)' vertical-align='middle' type='text' name='lname' />之间");
			out.print("</form>");
		}
		else if(q.equals("style")){
			out.print("<select id='style0"+a+"' name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			out.print("<option value='null'>--请选择操作类型--</option>");
			out.print("<option value='1'>存款</option>");
			out.print("<option value='0'>取款</option>");
			out.print("</select>");
		}
		else if(q.equals("date")){
			out.print("从<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 1970; i <= 2018; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>年 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 1; i <= 12; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>月 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 1; i <= 30; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>日 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 0; i <= 23; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>时 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 0; i <= 59; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>分 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 0; i <= 59; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>秒 &nbsp;&nbsp;");
			
			out.print("<br>");
			
			out.print("到<select name='customers' onchange='showCustomer(this.value)'>");
			for(int i = 1970; i <= 2018; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>年 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 1; i <= 12; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>月 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 1; i <= 30; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>日 &nbsp;&nbsp;");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 0; i <= 23; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>时&nbsp;&nbsp; ");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 0; i <= 59; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>分&nbsp;&nbsp; ");
			
			out.print("<select name='customers' onchange='showCustomer(this.value)' vertical-align='middle'>");
			for(int i = 0; i <= 59; i++){
				out.print("<option value='" + i + "'>" + i + "</option>");
			}
			out.print("</select>秒 &nbsp;&nbsp;");
		}
		else if(q.equals("yue")){
			out.print("<form action='' vertical-align='middle'>");
			out.print("在<input style='width:120px;' id='yue0' value='0' onchange='showCustomer(this.value)' vertical-align='middle' type='text' name='fname' />");
			out.print("—<input style='width:120px;' id='yue1' value='MAX' onchange='showCustomer(this.value)' vertical-align='middle' type='text' name='lname' />之间");
			out.print("</form>");
		}
		out.flush();
		out.close();
	}
}
